package org.example.zsfmybatis.service;


import org.example.zsfmybatis.mapper.RestaurantMapper;
import org.example.zsfmybatis.model.Restaurant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class RestaurantService {

    @Autowired
    private RestaurantMapper restaurantMapper;

    public List<Restaurant> getAllRestaurants() {
        return restaurantMapper.selectList(null);
    }

    public Restaurant getRestaurantById(int id) {
        return restaurantMapper.selectById(id);
    }

    public void addRestaurant(Restaurant restaurant) {
        restaurantMapper.add(restaurant);
    }

    public void updateRestaurant(int id, String name, String address, double rating) {
        restaurantMapper.update(id, name, address, rating);
    }

    public void deleteRestaurant(int id) {
        restaurantMapper.delete(id);
    }
}